<?php
namespace Shama\Company;
/**
 * Contact Partners.
 *
 * It represant a contact partner of a contact
 *
 * @author Xavier VILAIN
 * @package Shama\Contact
 *
 * @property int	$companyid	Id of the Contact (Parent)
 * @property string $role 		Partner Role
 * @property string $contactid 	Id of Partner
 */
class Partner extends \Fox\Object {

	/**
	 * Link to the Company
	 */
	const LINK_COMPANY = "company";

	/**
	 *
	 * Link to the Contact Object
	 */
	const LINK_CONTACT = "contact";

	/**
	 * Default Contact
	 * @var string
	 */
	const CONTACT_DEFAULT = "CPD";

	/**
	 * Contact
	 * @var string
	 */
	const CONTACT_PARTNER = "CP";

	/**
	 *
	 * Get id of the partner according to the parnter type
	 */
	public function partnerid()
	{
		return $this->partnerid;
	}

	/**
	 * Unique Id in sales objects
	 */
	public function salesId()
	{
		return $this->role.":".$this->partnerid();
	}
}
\Fox\Dao::infos(Partner::className(),new \Fox\Object\Info('company_partners', \Fox\Databases::DB_APP));

// Link to Company Type
\Fox\Object\Links::add(\Fox\Dao::link(Partner::className(),Partner::LINK_CONTACT)
	->to(\Shama\Contact::className(),\Shama\Contact::LINK_COMPANY)
	->oneToOne()
	->on('contactid'));